Description:
C#
allows you to replace the type check (is) and type cast operators with the single as
operator. This makes the code clearer and improves performance.
Incorrect:
if (obj is string) {
string str = (string)obj;
return str.Length;
}
Correct:
string str = obj as string;
if (str != null) {
return str.Length;
}